package top.codecrab.javase;

import java.io.*;
import java.net.Socket;

/**
 * @author codecrab
 * @since 2021年07月05日 12:56
 */
public class Client {
    public static void main(String[] args) {
        Socket socket = null;
        try {
            // 与服务端建立连接
            socket = new Socket("127.0.0.1", 8001);
//            socket.setSoTimeout(5000);
            // 往服务写数据
            Writer writer = new OutputStreamWriter(socket.getOutputStream());
            writer.write("有没有收到\n");
            writer.flush();
            BufferedReader br = new BufferedReader(new InputStreamReader(socket.getInputStream()));
            System.out.println(br.readLine());
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
